#include <iostream>
#include <QCoreApplication>
#include <FlatpakList.h>

#define out qDebug()

using namespace Flatpak;

QString makespace(int count, QString prefix) {
    QString result = "";
    int remain = count - prefix.length();
    for (int i = 0; i < remain; i++)
    {
        result.append(" ");
    }
    return result;
}

int main(int argc, char** argv) {

    QCoreApplication app(argc, argv);

    // Name/Application ID//Version/Branch/Origin/Installation
    QStringList lines = List().column_name().column_arch().column_application().onlyApp().ostree_verbose().run().split("\n");
    for (auto s : lines)
    {
        QStringList ss = s.split("\t");
        auto prefix = QString("%1(%2)").arg(ss[0]).arg(ss[1]);
        out << prefix + makespace(20, prefix) + "  --  " + ss[2];
    }

    return 0;
}